extends "../../azurlane_ctrl/AzurItem.gd"
func init():
	.init()
	name = "舰载机"
	price = 50

func _connect():
	if sys.main == null:return
	if masCha.getSkill("castPlane") == null:
		if masCha.id != "merchant":
			delFromCha()
	else:
		masCha.crewEquip = planeId
		masCha.crewEquipName = name
		delSelf()

func toJson():
	var json = .toJson()
	json["rare"] = rare
	json["planeId"] = planeId
	return json

func fromJson(json):
	.fromJson(json)
	rare = json.get("rare")
	planeId = json.get("planeId")
	postInit(rare, planeId)

var rare:bool = false
var planeId
func postInit(rare = false, id = null):
	if id == null:
		planeId = chaData.getRndPlane(rare)
	else:
		planeId = id

	var chara = chaData.getPlaneInfo(planeId)
	if rare:
		self.rare = true
		name = "[color=#FFFF00][稀有]" + chara.name
	else:
		name = chara.name
	info = "技能组：\n"

	var sks = []
	for i in chara.skills:
		sks.append(i.split("{tmpName}")[0])
	sks.pop_front()
	for i in sks:
		info += i + "\n"

	info += "[color=#DC143C]给航母装备后消失，航母将在战斗中召唤此型号的舰载机"

	